package com.lzm.ydpt.mvp.presenterimpl;

import com.byt.framlib.basemvp.BasePresenter;
import com.byt.framlib.basemvp.basebean.BaseResponseBean;
import com.byt.framlib.basemvp.exception.ApiException;
import com.byt.framlib.basemvp.listener.OnLoadingErrorListener;
import com.byt.framlib.basemvp.listener.OnLoadingProgressListener;
import com.google.gson.JsonObject;
import com.lzm.ydpt.module.mall.activity.MallAddEdtAddressActivity;
import com.lzm.ydpt.mvp.api.ProgressSubscriber;
import com.lzm.ydpt.mvp.contract.MallAddEdtAddressContract;
import com.lzm.ydpt.mvp.modelimpl.MallAddEdtAddressModelImpl;

/**
 * 类名称：MallAddEdtAddressPresenterImpl
 * 类描述：代理实现
 */
public class MallAddEdtAddressPresenterImpl extends BasePresenter implements MallAddEdtAddressContract.Presenter {

    private MallAddEdtAddressContract.View mView;
    private MallAddEdtAddressContract.Model mModel;

    public MallAddEdtAddressPresenterImpl(MallAddEdtAddressActivity context) {
        super(context);
        this.mView = context;
        this.mModel = new MallAddEdtAddressModelImpl();
    }

    @Override
    public void onMallAddEdtAddress() {
        mManager.http(mModel.onMallAddEdtAddress(), getLifecycleProvider(), new ProgressSubscriber<>(mContext, new OnLoadingProgressListener<JsonObject>() {
            @Override
            public void onLoadingResult(BaseResponseBean<JsonObject> entity) {
                mView.onMallAddEdtAddress();
            }
        }, new OnLoadingErrorListener() {
            @Override
            public void onError(ApiException e, String method) {
                mView.showMessage(e.getDisplayMessage(),method);
            }

            @Override
            public void onErrorResult(BaseResponseBean entity, String method) {
                mView.showMessage(entity.getMessage(),method);
            }
        }, "onMallAddEdtAddress"));
    }
}